﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
    xmlns:Mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"    
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
	mc:Ignorable="d"
	x:Class="Tfs.OnTheRoad.Controls.WorkItemsOverviewChartControl"
	d:DesignWidth="480" d:DesignHeight="800"
    x:Name="ChartControl" Loaded="ChartControl_Loaded">

    <Grid x:Name="summaryGrid">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="FindWorkItemPanes" ic:ExtendedVisualStateManager.UseFluidLayout="True">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.5">
                        <VisualTransition.GeneratedEasingFunction>
                            <ExponentialEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="SettingsVisible">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ChartSettingsPane">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="SettingsInvisible">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ChartSettingsPane">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <VisualStateManager.CustomVisualStateManager>
            <ic:ExtendedVisualStateManager/>
        </VisualStateManager.CustomVisualStateManager>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <toolkit:PerformanceProgressBar Height="20" IsIndeterminate="True" Visibility="{Binding Processing, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <StackPanel Grid.Row="0" Orientation="Horizontal" Visibility="{Binding ElementName=workItemsChart,Path=Visibility}">
            <TextBlock>Work Items:</TextBlock>
            <TextBlock Text="{Binding WorkItemsCount}"  Foreground="{StaticResource PhoneAccentBrush}"/>            
        </StackPanel>
        <charting:Chart  Grid.Row="1" Visibility="Collapsed" 
                x:Name="workItemsChart"                                                       
                Style="{StaticResource PhoneChartStyle}">              
        </charting:Chart>
        <StackPanel Visibility="{Binding ElementName=workItemsChart,Path=Visibility}" Grid.RowSpan="2" Margin="0,-12,0,0" HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal" >
            <Image Source="/Images/appbar.feature.settings.dropShadow.rest.png" Width="40">
            </Image>
            <HyperlinkButton HorizontalAlignment="Left" Content="Settings" Foreground="{StaticResource PhoneAccentBrush}">
                <Interactivity:Interaction.Triggers>
                    <Interactivity:EventTrigger EventName="Click">
                        <ic:GoToStateAction StateName="SettingsVisible"/>
                    </Interactivity:EventTrigger>
                </Interactivity:Interaction.Triggers>
            </HyperlinkButton>
        </StackPanel>
      
        <Border Grid.RowSpan="2" x:Name="ChartSettingsPane" MaxHeight="340"  Visibility="Collapsed" Background="{StaticResource PhoneBackgroundBrush}" CornerRadius="25,0,25,0" Margin="8" BorderThickness="4" BorderBrush="{StaticResource PhoneAccentBrush}">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Margin="10,0,0,0" Foreground="{StaticResource PhoneForegroundBrush}" 
                           FontWeight="Bold" FontSize="20" Text="Chart Settings" HorizontalAlignment="Center"/>
                <Grid Margin="0" Grid.Row="1" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Style="{StaticResource PhoneTextAccentStyle}"  Grid.Row="0" Grid.ColumnSpan="3" Text="Chart Type"/>

                    <toolkit:ListPicker x:Name="chartTypePicker" 
                                        Margin="10"  Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" 
                                        ItemsSource="{Binding ChartStrategies}" 
                                        SelectedItem="{Binding CurrentChartStrategy}" FullModeHeader="Select a Chart Type">
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                    </toolkit:ListPicker>


                    <TextBlock Style="{StaticResource PhoneTextAccentStyle}"  Grid.Row="2" Grid.Column="0" Text="Field 1"/>
                    <TextBlock Style="{StaticResource PhoneTextAccentStyle}"   Grid.Row="2" Grid.Column="1" Text="Field 2"
                               Visibility="{Binding SelectedItem.IsStacked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=chartTypePicker}" 
                               />

                    <toolkit:ListPicker x:Name="field1Picker" 
                                        SelectedItem="{Binding ElementName=chartTypePicker,Path=SelectedItem.Field1}"
                                        Margin="10"  Grid.Row="3" Grid.Column="0" ItemsSource="{Binding ChartFields}"
                                        FullModeHeader="Select the 1st field">
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                    </toolkit:ListPicker>
                    <toolkit:ListPicker x:Name="field2Picker" 
                                        SelectedItem="{Binding ElementName=chartTypePicker,Path=SelectedItem.Field2}"
                                        Visibility="{Binding ElementName=chartTypePicker,Path=SelectedItem.IsStacked, Converter={StaticResource BooleanToVisibilityConverter}}" 
                                        Margin="10"  Grid.Row="3" Grid.Column="1" ItemsSource="{Binding ChartFields}" 
                                        FullModeHeader="Select the 2nd field">
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                    </toolkit:ListPicker>

                    <Button HorizontalAlignment="Right" Margin="0,10,0,0" Width="150" Style="{StaticResource ButtonStyle}" Grid.Column="1" Grid.Row="4" Content="OK" Click="OKButton_Click">
                        <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="Click">
                                <ic:GoToStateAction StateName="SettingsInvisible"/>
                            </Interactivity:EventTrigger>
                        </Interactivity:Interaction.Triggers>
                    </Button>

                    <Button HorizontalAlignment="Left" Margin="0,10,0,0" Width="150" Style="{StaticResource ButtonStyle}" Grid.Column="0" Grid.Row="4" Content="Cancel">
                        <Interactivity:Interaction.Triggers>
                            <Interactivity:EventTrigger EventName="Click">
                                <ic:GoToStateAction StateName="SettingsInvisible"/>
                            </Interactivity:EventTrigger>
                        </Interactivity:Interaction.Triggers>
                    </Button>
                </Grid>

            </Grid>
        </Border>
    </Grid>
</UserControl>